{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "259c6ff8",
   "metadata": {},
   "source": [
    "________________\n",
    "* 2022/10/10/week07\n",
    "* Python学习记录\n",
    "________________"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "298316e5",
   "metadata": {},
   "source": [
    " # 本周内容\n",
    " \n",
    " * 1.有序的数据结构——字符串(str)\n",
    " * 2.有序的数据结构——列表(list)\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "516cf3a3",
   "metadata": {},
   "source": [
    "# 1.字符串(string)\n",
    "\n",
    "> 1. 关于字符串的基本内容\n",
    "> 2. 关于字符串的方法及函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f4d24940",
   "metadata": {},
   "source": [
    "## 1.1关于字符串的基本内容\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6f15e5c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'spam eggs'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'spam eggs'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "833a4f94",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type('spam eggs'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "cfec8143",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(\"spam eggs\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "b804be70",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3578565646.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [50]\u001b[1;36m\u001b[0m\n\u001b[1;33m    'doesn't'\u001b[0m\n\u001b[1;37m           ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "'doesn't'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "be832d2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 以上解决方案\n",
    "\"doesn't\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "25323c24",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"dont't\""
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'dont\\'t'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "212aaff6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 三引号：保留字符串信息的 格式信息，保留完整的数据信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "2b7072a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''doesn't'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "faa088f8",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "EOL while scanning string literal (2251390238.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [55]\u001b[1;36m\u001b[0m\n\u001b[1;33m    \"Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\u001b[0m\n\u001b[1;37m                                                                                                                      ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m EOL while scanning string literal\n"
     ]
    }
   ],
   "source": [
    "\"Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
    "\n",
    "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "22876272",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
      "\n",
      "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is\n"
     ]
    }
   ],
   "source": [
    "print('''Triple quoted strings may span multiple lines - all associated whitespace will be included in the string literal.\n",
    "\n",
    "String literals that are part of a single expression and have only whitespace between them will be implicitly converted to a single string literal. That is''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "e6e8c366",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Usage: thingy [OPTIONS]\n",
      "     -h                        Display this usage message\n",
      "     -H hostname               Hostname to connect to\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(\"\"\"\\\n",
    "Usage: thingy [OPTIONS]\n",
    "     -h                        Display this usage message\n",
    "     -H hostname               Hostname to connect to\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "7ba79763",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<script type=\"importmap\" nonce=\"\"> { \"imports\": {\"rms-answers-HomepageVNext-PeregrineWidgets\":\"https://assets.msn.com/bundles/v1/bingHomepage/latest/widget-initializer.js\"} } </script>\n"
     ]
    }
   ],
   "source": [
    "print('''<script type=\"importmap\" nonce=\"\"> { \"imports\": {\"rms-answers-HomepageVNext-PeregrineWidgets\":\"https://assets.msn.com/bundles/v1/bingHomepage/latest/widget-initializer.js\"} } </script>''')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7314fbb",
   "metadata": {},
   "source": [
    "###  1.2[关于字符串的方法及函数]\n",
    "\n",
    "> 1. 字符串是可以拼接的(字符串的运算），用 + 进行字符之间的拼接\n",
    "> 2. 字符串是有顺序的，从第一个字符开始，从0依次往后；有长度，可以用len()检查字符串的长度\n",
    "> 3. 字符串的取值：\n",
    ">> 1. 取单个值 ：从左往右（正数，第一个值是0），从右往左（负数，第一个值是-1）\n",
    ">> 2. 取多个值 ：切片的方法，两个值作为 取值的区间\n",
    "> 4. 字符串的方法及函数\n",
    ">> 1. in 查询成员是否存在\n",
    ">> 2. str.count() 查询数量\n",
    ">> 3. str.isdigit()判断字符串是否是数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8a688cc9",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_name = [\"小明\",\"小红\",\"李华\",\"小张\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "69006520",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院团委欢迎小明\n",
      "广州南方学院团委欢迎小红\n",
      "广州南方学院团委欢迎李华\n",
      "广州南方学院团委欢迎小张\n"
     ]
    }
   ],
   "source": [
    "for i in new_name:\n",
    "    print(\"广州南方学院团委欢迎\"+i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "2c0325d7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"广州南方学院团委欢迎\"+\"小明\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "cf32aa0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text = '广州南方学院团委欢迎小明'\n",
    "text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "616f698f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "0add5e30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'州'"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "c76ff51e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'南'"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "f3cd4497",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [61]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mtext\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m12\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[1;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "text[12]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "37f101d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "ae7e829c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[6]+text[7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "476fff9c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用 切片 的方法进行多个取值\n",
    "text[6:8]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a168e113",
   "metadata": {},
   "source": [
    "* in查询成员"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "953f3e8f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'广州'in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "fec9438b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'北京'in text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aae773de",
   "metadata": {},
   "source": [
    "* str.count() 查询数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "449b77c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.count('广州')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a6d0be6",
   "metadata": {},
   "source": [
    "* str.isdigit()判断字符串是否是数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "1e6a64a4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19 <class 'int'>\n",
      "19 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "age_li = 19\n",
    "age_wang = '19'\n",
    "print(age_li,type(age_li))\n",
    "print(age_wang,type(age_wang))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b7a7bc28",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_wang.isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "ceed8445",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.isdigit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c1193c9c",
   "metadata": {},
   "source": [
    "## 2.有序的数据结构——列表(list)\n",
    "\n",
    "* \n",
    "\n",
    "> 1. 列表的基本运算法则（参考：有序的数据结构的运算法则列表） \n",
    "> 2. 列表的一般方法（要求：全部掌握，并且做总结在课后笔记中）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ef4d88d",
   "metadata": {},
   "source": [
    "### 2.1 列表的基本运算法则"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "dccf024a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 思考：假设，有这样一个场景，我要录入/存放一个班同学的信息（名单信息），用字符串存放是否可行？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "c1ab421d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串存放\n",
    "网二_name = \"王诠胜，黄雨萱，昆布，李子维，陈韵如,莫俊杰\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "ba910edd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "22"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "45b9fd34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'王诠'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串取值，比较麻烦\n",
    "网二_name[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "a4532b93",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'，黄'"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "b03c129c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'萱，昆'"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[6:9]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d041a39a",
   "metadata": {},
   "source": [
    "* 对比字符串和列表\n",
    "\n",
    "> 1. 字符串是按照字符进行数据取值\n",
    "> 2. 列表是按照元素进行数据取值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "8d9c4a91",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_name_list = [\"王诠胜\",\"黄雨萱\",\"昆布\",\"李子维\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "c04afa59",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "19bf9773",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'王诠胜'"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "464a3419",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['王诠胜', '黄雨萱']"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "4986d84a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['昆布', '李子维']"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[-2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "9cdc4672",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_age_list = [19,18,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "8ced4d97",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19, 18, 19, 20]"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list[:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "423f88eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20]"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list*5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "90cabf7b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list.count(19)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b2de762",
   "metadata": {},
   "source": [
    "### 2.2 列表的方法\n",
    "\n",
    "> 1. 增加\n",
    "> 2. 删除\n",
    "> 3. 修改\n",
    "> 4. 查询 in,count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "c35ef8b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"Mike\",\"Marry\",\"Jan\",\"Jake\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5088f5c",
   "metadata": {},
   "source": [
    "* 学习方法\n",
    "> 1. listname.Tab键 查看所有方法名称\n",
    "> 2. help(listnames.function)查看其中一个方法的具体操作内容\n",
    "\n",
    "> 课后练习（做一个表格，总结列表的方法）: \n",
    "\n",
    "| 列表方法        |      Description       |       备注\n",
    "|------------------- |------------------------------|------------------------\n",
    "|  append()       |增加元素，增加在列表的末尾   |\n",
    "|  count()        |统计某个元素在列表中出现的次数|               \n",
    "| extend()        |在列表末尾一次性追加另一个序列中的多个值（用新列表拓展原来的列表）\n",
    "| index()         |从列表中找出某个值第一个匹配项的索引个位置                             \n",
    "| insert()        |     将对象插入列表                                        \n",
    "|pop()           |移除列表中的一个元素（默认最后一个元素），并返回该元素的值\n",
    "|   remove()       |     移除列表中某个值的第一个匹配项                                      \n",
    "|    reverse()      |    反向列表中元素                                      \n",
    "|     sort()      |        对原列表进行排序   \n",
    "|clear()           |  清空列表\n",
    "|copy()          |复制列表\n",
    "|\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "083bf0aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"xuanyi\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "74b9fa61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Marry', 'Jan', 'Jake', 'xuanyi', 'xuanyi']"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "5a124e82",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "7e69f947",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(1,\"Alex\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "a2b39090",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Alex', 'Marry', 'Jan', 'Jake', 'xuanyi', 'xuanyi']"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
